﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using Angel.Daos.IManager;
using Angel.Daos.Manager;

namespace Angel.Web.Models
{
    public class SearchGroupModels
    {
        [Required]
        [Display(Name = "Group Name")]
        public string NameGroup { get; set; }
    }


    public class CreateGroupModel
    {
        [AllowHtml]
        [CustomValidation(typeof(CreateGroupModel), "ValidateDuplicateGroupName")]
        [Required(ErrorMessage="You must specify valid group name.")]
        [Display(Name = "Group name")]     
        public string NameGroup { get; set; }
        public static ValidationResult ValidateDuplicateGroupName(String groupName)
        {
            bool isValid;
            IGroupManager userManager = new GroupManager();
            if (userManager.CheckGroupName(groupName))
            {
                isValid = false;
            }
            else
            {
                isValid = true;
            }
            if (isValid)
            {
                return ValidationResult.Success;
            }
            else
            {
                return new ValidationResult("A group with this name already exists.");
            }
        }
    }
    public class EditGroupModel
    {
        [Required]
        [Display(Name = "Group name")]
        public int id { get; set; }
    }
    public class DeleteGroupModel
    {
        [Required]
        [Display(Name = "Group name")]
        public int id { get; set; }
        public string name { get; set; }
    }
    public class MemberGroup
    {
        [Required]
        public string UserName { get;set; }        
        [Required]
        public int GroupId { get; set; }
    }
    public class FilterResultModel
    {
        public int Rows { get; set; }
        public int Pages { get; set; }
        public int CurrentPage { get; set; }
        public int StartRow { get; set; }
        public IEnumerable<FilterGroupModel> Groups { get; set; }
        public FilterResultModel(int _rows, int _pages, int _currentPage, int _startRow, IEnumerable<FilterGroupModel> _groups)
        {
            Rows = _rows;
            Pages = _pages;
            CurrentPage = _currentPage;
            StartRow = _startRow;
            Groups = _groups;
        }
    }
    public class FilterGroupModel
    {
        public int Id { get; set; }
        public String Name { get; set; }
        public int NumberOfUser { get; set; }
        public FilterGroupModel(int _id, String _name, int _numberOfUser)
        {
            Id = _id;
            Name = _name;
            NumberOfUser = _numberOfUser;
        }
    }
    public class JsonInfo
    {
        public String Name { get; set; }
        public int Start { get; set; }
        public int Max { get; set; }
    }
}